﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              x:Class="TaskManager.View.TaskLogView"
             mc:Ignorable="d" d:DesignWidth="200">

    <Border x:Name="border" CornerRadius="5" BorderThickness="1" BorderBrush="#FF1D1D1D">
        <Border.Style>
            <Style>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Status}" Value="Completed">
                        <Setter Property="Border.Background">
                            <Setter.Value>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <LinearGradientBrush.RelativeTransform>
                                        <TransformGroup>
                                            <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                                            <SkewTransform CenterY="0.5" CenterX="0.5"/>
                                            <RotateTransform Angle="-90" CenterY="0.5" CenterX="0.5"/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </LinearGradientBrush.RelativeTransform>
                                    <GradientStop Color="#FF878484" Offset="0.7"/>
                                    <GradientStop Color="#FF53974E" Offset="1"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Status}" Value="Faulted">
                        <Setter Property="Border.Background">
                            <Setter.Value>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <LinearGradientBrush.RelativeTransform>
                                        <TransformGroup>
                                            <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                                            <SkewTransform CenterY="0.5" CenterX="0.5"/>
                                            <RotateTransform Angle="-90" CenterY="0.5" CenterX="0.5"/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </LinearGradientBrush.RelativeTransform>
                                    <GradientStop Color="#FF878484" Offset="0.7"/>
                                    <GradientStop Color="#FFC04343" Offset="1"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Status}" Value="Canceled">
                        <Setter Property="Border.Background">
                            <Setter.Value>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <LinearGradientBrush.RelativeTransform>
                                        <TransformGroup>
                                            <ScaleTransform CenterY="0.5" CenterX="0.5"/>
                                            <SkewTransform CenterY="0.5" CenterX="0.5"/>
                                            <RotateTransform Angle="-90" CenterY="0.5" CenterX="0.5"/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </LinearGradientBrush.RelativeTransform>
                                    <GradientStop Color="#FF878484" Offset="0.7"/>
                                    <GradientStop Color="#FFC2CA34" Offset="1"/>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Border.Style>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <StackPanel Visibility="{Binding Error, ConverterParameter=True, Converter={StaticResource NullToVisibilityConverter}}" Orientation="Vertical" Margin="10,3" Height="23">
                <TextBlock Text="{Binding Name}" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis" Foreground="White" VerticalAlignment="Center" />
            </StackPanel>

            <StackPanel Visibility="{Binding Error, Converter={StaticResource NullToVisibilityConverter}}" Orientation="Vertical" Margin="10,3">
                <Expander Header="{Binding Name}" HorizontalAlignment="Left" Foreground="White" ExpandDirection="Down">
                    <ScrollViewer MaxHeight="200">
                        <TextBox Text="{Binding Error}" TextWrapping="Wrap" IsReadOnly="True" />
                    </ScrollViewer>
                </Expander>
            </StackPanel>

            <StackPanel Orientation="Horizontal" Grid.Column="1">
                <Button Visibility="{Binding IsClearPossible, Converter={StaticResource BoolToVisibilityConverter}}" 
                        Command="{Binding ClearCommand}" Style="{StaticResource CancelButtonStyle}" 
                        Margin="0,5,10,0" VerticalAlignment="Top" ToolTip="Clear" />
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
